from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime

class LogEntry(BaseModel):
    createdAt: str
    message: str

class OutputFile(BaseModel):
    id: str
    name: str
    type: str
    size: int

class ExecutionRecordBase(BaseModel):
    taskId: str
    taskTitle: str
    taskGuide: str
    status: str
    duration: str
    category: str
    error: Optional[str] = None
    logs: Optional[List[LogEntry]] = None
    screenshot: Optional[str] = None
    outputFiles: Optional[List[OutputFile]] = None

class ExecutionRecordCreate(ExecutionRecordBase):
    id: str

class ExecutionRecordUpdate(BaseModel):
    status: Optional[str] = None
    duration: Optional[str] = None
    error: Optional[str] = None
    logs: Optional[List[LogEntry]] = None
    screenshot: Optional[str] = None
    outputFiles: Optional[List[OutputFile]] = None

class ExecutionRecord(ExecutionRecordBase):
    id: str
    createdAt: str

    class Config:
        from_attributes = True 